package com.zxl.live.screen.screen.utils;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Camera;
import android.graphics.Matrix;

import com.zxl.live.screen.screen.ui.widget.panel.DandelionScreenSpirit;
import com.zxl.live.screen.screen.ui.widget.panel.HeartScreenPanel;
import com.zxl.live.screen.screen.ui.widget.panel.SakuraScreenSpirit;
import com.zxl.live.screen.screen.ui.widget.panel.ScreenSpirit;
import com.zxl.live.screen.screen.ui.widget.panel.SnowScreenSpirit;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class Global {

    public static final String[] SAKURA_PINK_BITMAPS_NAME = {
            "sakura_white_1", "sakura_white_1", "sakura_white_2",
            "sakura_white_3", "sakura_white_4", "sakura_white_5",
            "sakura_white_6", "sakura_white_7", "sakura_pink_1",
            "sakura_pink_1", "sakura_pink_2", "sakura_pink_3", "sakura_pink_4",
            "sakura_pink_5", "sakura_pink_6", "sakura_pink_7"};

    public static final String[] SNOWFLAKE_BITMAPS_NAME = {"snow_flake", "flake01", "flake02", "flake03", "flake04", "flake05", "flake06"};

    public static final String[] TAOHUA_BITMAPS_NAME = {"taohua1", "taohua2", "taohua3", "taohua4", "taohua5", "taohua6"};

    public static final String[] ROSE_BITMAPS_NAME = {"rose1", "rose2", "rose3", "rose4", "rose5", "rose6"};

    private static final String[] DANDE_BITMAPS_NAME = {"dandelion"};

    private static final String[] HEART_ROSE_BITMAPS_NAME = {"rose", "rose1", "taohua4", "rose5", "taohua1"};

    /**
     * 红色樱花
     *
     * @param context
     * @param mCamera
     * @param mMatrix
     * @param mRandom
     * @param size
     */
    public static List<ScreenSpirit> createRedSakura(Context context, Camera mCamera, Matrix mMatrix, Random mRandom, int size) {
        BitmapLoaderUtils bitmapLoader = BitmapLoaderUtils.getsInstance(context);
        Bitmap[] mSakuraRedBitmaps = new Bitmap[SAKURA_PINK_BITMAPS_NAME.length];
        for (int i = 0; i < SAKURA_PINK_BITMAPS_NAME.length; ++i) {
            mSakuraRedBitmaps[i] = bitmapLoader.getBitmap(SAKURA_PINK_BITMAPS_NAME[i]);
        }
        List<ScreenSpirit> list = new ArrayList<>();
        for (int i = 0; i < size; i++) {
            list.add(new SakuraScreenSpirit(mCamera, mMatrix, mSakuraRedBitmaps[mRandom.nextInt(mSakuraRedBitmaps.length)], mRandom));
        }
        return list;
    }

    /**
     * 雪
     *
     * @param context
     * @param mRandom
     * @param size
     */
    public static List<ScreenSpirit> createSnow(Context context, Random mRandom, int size) {
        BitmapLoaderUtils bitmapLoader = BitmapLoaderUtils.getsInstance(context);
        Bitmap[] mSnowBitmaps = new Bitmap[SNOWFLAKE_BITMAPS_NAME.length];
        for (int i = 0; i < SNOWFLAKE_BITMAPS_NAME.length; ++i) {
            mSnowBitmaps[i] = bitmapLoader.getBitmap(SNOWFLAKE_BITMAPS_NAME[i]);
        }
        List<ScreenSpirit> list = new ArrayList<>();
        for (int i = 0; i < size; i++) {
            list.add(new SnowScreenSpirit(mSnowBitmaps[mRandom.nextInt(mSnowBitmaps.length)], mRandom));
        }
        return list;
    }

    /**
     * 桃花
     *
     * @param context
     * @param mCamera
     * @param mMatrix
     * @param mRandom
     * @param size
     */
    public static List<ScreenSpirit> createTaohua(Context context, Camera mCamera, Matrix mMatrix, Random mRandom, int size) {
        BitmapLoaderUtils bitmapLoader = BitmapLoaderUtils.getsInstance(context);
        Bitmap[] mTaohuaBitmaps = new Bitmap[TAOHUA_BITMAPS_NAME.length];
        for (int i = 0; i < TAOHUA_BITMAPS_NAME.length; ++i) {
            mTaohuaBitmaps[i] = bitmapLoader.getBitmap(TAOHUA_BITMAPS_NAME[i]);
        }
        List<ScreenSpirit> list = new ArrayList<>();
        for (int i = 0; i < size; i++) {
            list.add(new SakuraScreenSpirit(mCamera, mMatrix, mTaohuaBitmaps[mRandom.nextInt(mTaohuaBitmaps.length)], mRandom));
        }
        return list;
    }

    /**
     * 　玫瑰
     *
     * @param context
     * @param mCamera
     * @param mMatrix
     * @param mRandom
     * @param size
     */
    public static List<ScreenSpirit> createRose(Context context, Camera mCamera, Matrix mMatrix, Random mRandom, int size) {
        BitmapLoaderUtils bitmapLoader = BitmapLoaderUtils.getsInstance(context);
        Bitmap[] mRoseBitmaps = new Bitmap[ROSE_BITMAPS_NAME.length];
        for (int i = 0; i < ROSE_BITMAPS_NAME.length; ++i) {
            mRoseBitmaps[i] = bitmapLoader.getBitmap(ROSE_BITMAPS_NAME[i]);
        }

        List<ScreenSpirit> list = new ArrayList<>();
        for (int i = 0; i < size; i++) {
            list.add(new SakuraScreenSpirit(mCamera, mMatrix, mRoseBitmaps[mRandom.nextInt(mRoseBitmaps.length)], mRandom));
        }
        return list;
    }

    /**
     * 蒲公英
     *
     * @param context
     * @param mRandom
     * @param size
     */
    public static List<ScreenSpirit> createDandelion(Context context, Random mRandom, int size) {
        BitmapLoaderUtils bitmapLoader = BitmapLoaderUtils.getsInstance(context);
        Bitmap[] mXingBitmaps = new Bitmap[DANDE_BITMAPS_NAME.length];
        for (int i = 0; i < DANDE_BITMAPS_NAME.length; ++i) {
            mXingBitmaps[i] = bitmapLoader.getBitmap(DANDE_BITMAPS_NAME[i]);
        }

        List<ScreenSpirit> list = new ArrayList<>();
        for (int i = 0; i < size; i++) {
            list.add(new DandelionScreenSpirit(mXingBitmaps[mRandom.nextInt(mXingBitmaps.length)], mRandom));
        }
        return list;
    }

    /**
     * 心形玫瑰
     *
     * @param context
     * @param mRandom
     * @param size
     */
    public static List<ScreenSpirit> createHeartRose(Context context, Camera mCamera, Matrix mMatrix, Random mRandom, int size) {
        BitmapLoaderUtils bitmapLoader = BitmapLoaderUtils.getsInstance(context);
        Bitmap[] mHeartRoseBitmaps = new Bitmap[HEART_ROSE_BITMAPS_NAME.length];
        for (int i = 0; i < HEART_ROSE_BITMAPS_NAME.length; ++i) {
            mHeartRoseBitmaps[i] = bitmapLoader.getBitmap(HEART_ROSE_BITMAPS_NAME[i]);
        }

        List<ScreenSpirit> list = new ArrayList<>();
        for (int i = 0; i < size; i++) {
            list.add(new SakuraScreenSpirit(mCamera, mMatrix, mHeartRoseBitmaps[mRandom.nextInt(mHeartRoseBitmaps.length)], mRandom));
        }
        list.add(new HeartScreenPanel(null, null));
        return list;
    }
}
